﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CUREBusinessLogicLayer;

namespace CURE.SystemManagement
{
    public partial class DeptInformation : System.Web.UI.Page
    {
        #region 变量
        private string id;

        public string Id
        {
            get { return id; }
            set { id = value; }
        }
        private string dept_id;

        public string Dept_id
        {
            get { return dept_id; }
            set { dept_id = value; }
        }
        private string dept_name;

        public string Dept_name
        {
            get { return dept_name; }
            set { dept_name = value; }
        }
        private string action;

        public string Action
        {
            get { return action; }
            set { action = value; }
        }
        #endregion

        DeptBll deptbll = new DeptBll();
        protected void Page_Load(object sender, EventArgs e)
        {

            action = Request.QueryString["action"];
            if (action == "add")//新增
            {
                id = Request.QueryString["id"];
                dept_id = "";
                dept_name = "";
                txtDeptid.Value = "";
            }
            else if (action == "edit")//编辑
            {
                id = Request.QueryString["id"];
                dept_id = Request.QueryString["dept_id"];
                dept_name = GetDeptNameById(dept_id);
                txtDeptid.Value = dept_id;
                txtDeptid.Attributes["readonly "] = "readonly";
            }
        }

        /// <summary>
        /// 根据id获取部门名称
        /// </summary>
        /// <param name="dept_id">dept_id</param>
        /// <returns>部门名称</returns>
        public string GetDeptNameById(string dept_id)
        {
            string name = string.Empty;
            name = deptbll.GetDeptNameById(dept_id);
            return name;
        }
    }
}